package com.locationtracker.plus.ui.adapter

import android.graphics.Paint
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.locationtracker.plus.R
import com.locationtracker.plus.app.ext.removeZero
import com.locationtracker.plus.data.model.bean.RechargeResponse

class RechargeAdapter(data: MutableList<RechargeResponse>?) :
    BaseQuickAdapter<RechargeResponse, BaseViewHolder>(R.layout.item_recharge, data) {

    override fun convert(helper: BaseViewHolder, item: RechargeResponse) {
        item.run {
            helper.setText(R.id.recharge_item_per, item.badge)
                .setText(R.id.recharge_item_during, item.name)
                .setText(R.id.recharge_item_price, "\$ ${item.price.toString().removeZero()}")
                .setText(R.id.recharge_item_origin, "\$ ${item.delete_price.removeZero()}")
                .setText(R.id.recharge_item_tip, item.tip)
                .setGone(R.id.recharge_item_tip, item.tip.isBlank())

            helper.getView<TextView>(R.id.recharge_item_origin).paintFlags =
                Paint.STRIKE_THRU_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG

            helper.getView<View>(R.id.recharge_item_root).isSelected = item.selected
            helper.getView<View>(R.id.recharge_item_during).isSelected = item.selected
            helper.getView<View>(R.id.recharge_item_price).isSelected = item.selected
            helper.getView<View>(R.id.recharge_item_origin).isSelected = item.selected
        }
    }
}


